set -e
set -x
echo "start building.."
pwd
git status
echo "CI_COMMIT_REF_NAME = $CI_COMMIT_REF_NAME"
if [ x$CI_COMMIT_REF_NAME = xmaster ] ; then pkgname=$(date +%Y%m%d-%H%M%S); else pkgname=$(date +%Y%m%d-%H%M%S)-dev; fi
echo "<"'!'"--${pkgname}--"">" >> src/pages/document.ejs 
npm run build
cd dist
rm -f ../webdemo.pano.video.*.tar
tar -zcvf ../webdemo.pano.video.${pkgname}.tar ./
echo output ${pkgname}.tar
curl -u admin:P@ile0822 --upload-file ../webdemo.pano.video.${pkgname}.tar  http://repo.pano.video/repository/raw-hosted/webdemo/${pkgname}.tar
echo ${pkgname} > version
curl -u admin:P@ile0822 --upload-file ./version  http://repo.pano.video/repository/raw-hosted/webdemo/version
curl -XPOST http://static:L8gWmcD1AL@awx.pano.video/api/v2/job_templates/2288/launch/
# sleep 5
# sh ../cinotify.sh webclient ${pkgname}